package com.sun.hunk.struts.form;

import com.sun.hunk.hibernate.dao.ItemDAO;
import com.sun.hunk.hibernate.domain.Item;
import com.sun.hunk.hibernate.domain.Sales;
import com.sun.hunk.hibernate.domain.impl.DomainFactory;
import com.sun.hunk.struts.HunkActionForm;

/**
 *
 * @author sunil
 */
public class SalesForm extends HunkActionForm {

    private Sales sales;
    private String item;
    private String startDate;
    private String endDate;

    public SalesForm() {
        sales = DomainFactory.getSales();
    }

    public Long getId() {
        return sales.getId();
    }

    public void setId(Long id) {
        if (id != null && id > 0) {
            sales.setId(id);
        }
    }

    public String getItemCode() {
        Item item = sales.getItem();
        if (item != null) {
            return item.getCode();
        } else {
            return null;
        }
    }

    public void setItemCode(String item) {
        sales.setItem(new ItemDAO().getByCode(item));
    }

    public Sales getSales() {
        return sales;
    }

    public void setSales(Sales sales) {
        this.sales = sales;
    }

    public String getEndDate() {
        return endDate;
    }

    public void setEndDate(String endDate) {
        this.endDate = endDate;
    }

    public String getItem() {
        return item;
    }

    public void setItem(String item) {
        this.item = item;
    }

    public String getStartDate() {
        return startDate;
    }

    public void setStartDate(String startDate) {
        this.startDate = startDate;
    }
}
